﻿using Microsoft.AspNetCore.SignalR.Client;
using NewWms.Views;
using Prism.Commands;
using Prism.Regions;
using SignalR.Client;
using SingalR.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using WcsZz.Extend;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace NewWms.ViewModels
{
    public class MainWindowModel
    {
        public  MainWindowModel(IRegionManager regionManager)
        {
            OpenPageCommand = new DelegateCommand<string>(OpenPage);
            ClosePageCommand=new DelegateCommand<object>(ClosePage);
            _regionManager = regionManager;
            _regionManager.RegisterViewWithRegion("MainContent", typeof(UpAndDownShelvesView));
            EventAggregatorHelper.EventAggregator.ResgiterMessage(arg =>
            {
                OpenPage("BoxShelfView");
            }, "跳转页面");
           
        }

        public DelegateCommand<string> OpenPageCommand { get; set; }
        public DelegateCommand<object>ClosePageCommand { get; set; }
        private readonly IRegionManager _regionManager;


 


        //打开
        private async void OpenPage(string obj)
        {

            _regionManager.RequestNavigate("MainContent", obj);

        }
        //关闭
        private async void ClosePage(object obj)
        {
            _regionManager.Regions["MainContent"].Remove(obj);
        }

    }
}
